x1 = int(input())
y1 = int(input())
op = int(input())
x2 = int(input())
y2 = int(input())

if op == 1:
    x3 = x1*y2+x2*y1
    y3 = y1*y2
elif op == 2:
    x3 = x1*y2-x2*y1
    y3 = y1*y2
elif op == 3:
    x3 = x1*x2
    y3 = y1*y2
elif op == 4:
    x3 = x1*y2
    y3 = y1*x2

if x3 == 0:
    y3 = 1
    sign = 1
elif x3*y3 < 0:
    sign = -1
else:
    sign = 1

gcd = 1
x3,y3 = abs(x3),abs(y3)
for i in range(min(x3,y3),0,-1):
    if x3%i==0 and y3%i==0:
        gcd = i
        break
x3,y3 = x3//gcd,y3//gcd
x3 *= sign

print(x3)
print(y3)